﻿<form action="index.php" method="post" name="adminForm" >
<table>
<tr>
	<td><a href="index.php?c=product&t=addimage&productid=<?php echo sscls_Request::getRequest('productid') ?>" ><img src="<?php echo SITELIVE ?>tmpl/default/images/add.png"/>Thêm</a></td>
	<td><a href="javascript:void(0);" onclick="deleted();"  ><img src="<?php echo SITELIVE ?>tmpl/default/images/remove.png"/>Xóa</a></td>
	<td><a href="index.php?c=product"  ><img width="24" height="24" src="<?php echo SITELIVE ?>tmpl/default/images/back.png"/>Quay lai</a></td>
</tr>
</table>
<table width="100%" style="background-color: #E7E7E7;  border-spacing: 1px;  color: #666666;border: 1px solid back;">
	<tr style="background-color:#F0F0F0; border:1px solid silver;">
		<th><input type="checkbox" name="checkall1" onclick="checkall()" /></th>
		<th>Id</th>
		<th>Tiêu đề</th>
		<th>Tên images</th>
	</tr>
	<?php if(count($this->images)){ ?>
	<?php foreach((array)$this->images as $k=>$images){ ?>
	<tr style="<?php echo $k%2?'border-spacing: 1px;color: #666666;':'background: #F9F9F9;border-top: 1px solid #FFFFFF;'; ?>">
		<td><input type="checkbox" name="cid" value="<?php echo $images->id ?>" /></td>
		<td><?php echo $images->id ?></td>
		<td><a href="index.php?c=product&t=addimage&productid=<?php echo $images->productid ?>&id=<?php echo $images->id ?>"><?php echo $images->title ?></a></td>
		<td><?php echo $images->image_name ?></td>
	</tr>
	<?php }}else{?>
	<tr style="border-spacing: 1px;color: #666666;">
		<td colspan="4" align="center">Hiện chưa có hình nào trong sản phẩm này.</td>
	</tr>
	<?php }?>

</table>
<input type="hidden" name="c" value="product" />
<input type="hidden" name="productid" value="<?php echo sscls_Request::getRequest('productid') ?>" />
<input type="hidden" name="t" value="removeimage" />
</form>
<script>
	function checkall()
	{
		//var checkbox=document.adminForm.cid;
		for(i=0;i<document.adminForm.cid.length;i++)
		{
			if(document.adminForm.checkall1.checked==false)
				document.adminForm.cid[i].checked=false;
			else
				document.adminForm.cid[i].checked=true;
		}
	}
	
	function deleted()
	{
		var t=0;
		if(document.adminForm.cid.length>0)
		{
			for(i=0;i<document.adminForm.cid.length;i++)
			{
				if(document.adminForm.cid[i].checked==true)
					t=1;
			}
			if(t==0){
				alert('Vui lòng chọn một record!');
			}else 
			{
				var answer = confirm("Bạn chắc không?")
				if (answer){
					document.adminForm.submit();
				}
			}
		}else
		{
			if(document.adminForm.cid.checked==false){
				alert('Vui lòng chọn một record!');
			}else 
			{
				var answer = confirm("Bạn chắc không?")
				if (answer){
					document.adminForm.submit();
				}
			}
		}		
	}	
</script>
